package com.walter.configuration;

import com.walter.condition.HelloCondition;
import com.walter.prop.HelloServiceProperties;
import com.walter.service.HelloServiceConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
//@EnableConfigurationProperties(HelloServiceProperties.class)
//@ConditionalOnClass(HelloServiceConfiguration.class)
@Conditional(HelloCondition.class)
//@ConditionalOnProperty(prefix = "com.walter", value = "enabled", matchIfMissing = true)
public class HelloServiceAutoConfiguration {

    //@Autowired
    //private HelloServiceProperties helloServiceProperties;

//    @Bean
//    @ConditionalOnMissingBean(HelloServiceConfiguration.class)
//    public HelloServiceConfiguration helloServiceConfiguration() {
//        HelloServiceConfiguration helloService = new HelloServiceConfiguration();
//        helloService.setName(helloServiceProperties.getName());
//        helloService.setHobby(helloServiceProperties.getHobby());
//        return helloService;
//    }

    @Bean
    @Autowired
    public ApplicationRunner runner() {
        return args -> {
            System.out.println("Hello World");
        };
    }
}
